package com.xxzb.pack0822.多线程.线程调度;

public class 设置优先级Priority {
    public static void main(String[] args) {
        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }

            }
        },"t1");
        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }

            }
        },"t2");
//        Thread.MAX_PRIORITY:最高优先级10
//        Thread.MIN_PRIORITY:最低优先级1
//        Thread.NORM_PRIORITY:普通优先级5
        //设置优先级高就是说先执行完的概率高，不是说一定先执行完，
//        t2.setPriority(Thread.MAX_PRIORITY);//设置t2线程优先级最高
        t2.setPriority(10);
//        t1.setPriority(Thread.MIN_PRIORITY);//设置t1线程优先级最低
        t1.start();
        t2.start();

    }
}
